package top.sayto.simon.notificationlistener.ui.setting;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import top.sayto.simon.notificationlistener.databinding.FragmentSettingBinding;
import top.sayto.simon.notificationlistener.ui.helper.AddRuleDialogFragment;
import top.sayto.simon.notificationlistener.ui.helper.ToastUtil;

public class SettingFragment extends Fragment {

    private FragmentSettingBinding binding;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        SettingViewModel settingViewModel =
                new ViewModelProvider(this).get(SettingViewModel.class);

        binding = FragmentSettingBinding.inflate(inflater, container, false);
        View root = binding.getRoot();

//        保存按钮
        final Button saveBtn = binding.saveButton;
        saveBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                ToastUtil.showMsg("hello", v);
                AddRuleDialogFragment dialog = new AddRuleDialogFragment();
                dialog.show(getActivity().getSupportFragmentManager(), "tag");
            }
        });

//        final TextView textView = binding.textSetting;
//        settingViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}